﻿using System.Windows;
using System.Windows.Interactivity;

namespace Rhizome.QuickStart.Elevator.Behavior
{
    public sealed class ExecuteMethodAction : TargetedTriggerAction<DependencyObject>
    {
        public string MethodName { get; set; }

        protected override void Invoke(object parameter)
        {
            var dataContext = ((FrameworkElement) Target).DataContext;
            dataContext.GetType().GetMethod(MethodName).Invoke(dataContext, null);
        }
    }
}